public function &getCalculationRoleRefs( $filter = array(), $sort = true )
	{
		// Make sure the filter is initialized and contains lowercase values
		if ( ! is_array( $filter ) ) $filter = array();
		$filter = array_flip( array_map( 'strtolower', $filter ) );

		$refs = $this->context->calculationRoleRefs;

		/**
		 * @var array $result
		 */
		$result = array();

		foreach ( $refs as $refKey => $ref )
		{
			// Apply the filter if one is provided
			if ( count( $filter ) && ! isset( $filter[ strtolower( $refKey ) ] ) ) continue;

			$result[ $refKey ] = $this->context->calculationRoleRefs[ $refKey ];

			$description = $this->getCalculationLinkRoleDescription( $ref );
			$result[ $refKey ]['text'] = $description ? $description : "";

			// Remove any prohibited arcs
			if ( isset( $result[ $refKey ]['calculations'] ) && count( $result[ $refKey ]['calculations'] ) )
			{
				$arcs =& $result[ $refKey ]['calculations'];
				foreach ( $arcs as $from => $targets )
				{
					foreach ( $targets as $to => $node )
					{
						if ( $node['use'] == XBRL_Constants::$xlinkUseOptional ) continue;
						unset( $arcs[ $from ][ $to ] );
					}

					if ( count( $arcs[ $from ] ) ) continue;
					unset( $arcs[ $from ] );
				}
			}
		}

		if ( $sort )
		{
			$this->sortRoleRefs( $result );
		}

		return $result;
	}