xref: /AOO41X/main/svx/source/sidebar/SelectionAnalyzer.cxx (revision 03e5ec27dc901ad065aee89adc355f27c0b70501)
15d39f272SZheng Fan /**************************************************************
25d39f272SZheng Fan  *
35d39f272SZheng Fan  * Licensed to the Apache Software Foundation (ASF) under one
45d39f272SZheng Fan  * or more contributor license agreements.  See the NOTICE file
55d39f272SZheng Fan  * distributed with this work for additional information
65d39f272SZheng Fan  * regarding copyright ownership.  The ASF licenses this file
75d39f272SZheng Fan  * to you under the Apache License, Version 2.0 (the
85d39f272SZheng Fan  * "License"); you may not use this file except in compliance
95d39f272SZheng Fan  * with the License.  You may obtain a copy of the License at
105d39f272SZheng Fan  *
115d39f272SZheng Fan  *   http://www.apache.org/licenses/LICENSE-2.0
125d39f272SZheng Fan  *
135d39f272SZheng Fan  * Unless required by applicable law or agreed to in writing,
145d39f272SZheng Fan  * software distributed under the License is distributed on an
155d39f272SZheng Fan  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165d39f272SZheng Fan  * KIND, either express or implied.  See the License for the
175d39f272SZheng Fan  * specific language governing permissions and limitations
185d39f272SZheng Fan  * under the License.
195d39f272SZheng Fan  *
205d39f272SZheng Fan  *************************************************************/
215d39f272SZheng Fan 
225d39f272SZheng Fan #include "precompiled_svx.hxx"
235d39f272SZheng Fan 
245d39f272SZheng Fan #include "svx/sidebar/SelectionAnalyzer.hxx"
255d39f272SZheng Fan #include "svx/svdmrkv.hxx"
265d39f272SZheng Fan #include "svx/svdobj.hxx"
27*03e5ec27SOliver-Rainer Wittmann #include "svx/svdotext.hxx"
285d39f272SZheng Fan #include "svx/svdpage.hxx"
295d39f272SZheng Fan #include "svx/fmglob.hxx"
305d39f272SZheng Fan #include "svx/globl3d.hxx"
315d39f272SZheng Fan 
325d39f272SZheng Fan using sfx2::sidebar::EnumContext;
335d39f272SZheng Fan 
345d39f272SZheng Fan 
355d39f272SZheng Fan namespace svx { namespace sidebar {
365d39f272SZheng Fan 
375d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForSelection_SC (const SdrMarkList& rMarkList)
385d39f272SZheng Fan {
395d39f272SZheng Fan     EnumContext::Context eContext = EnumContext::Context_Unknown;
405d39f272SZheng Fan 
415d39f272SZheng Fan     switch (rMarkList.GetMarkCount())
425d39f272SZheng Fan     {
435d39f272SZheng Fan         case 0:
445d39f272SZheng Fan             // Empty selection.  Return Context_Unknown to let the caller
455d39f272SZheng Fan             // substitute it with the default context.
465d39f272SZheng Fan             break;
475d39f272SZheng Fan 
485d39f272SZheng Fan         case 1:
495d39f272SZheng Fan         {
505d39f272SZheng Fan             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
51*03e5ec27SOliver-Rainer Wittmann             if ( pObj->ISA(SdrTextObj) && ((SdrTextObj*)pObj)->IsInEditMode() )
52*03e5ec27SOliver-Rainer Wittmann             {
53*03e5ec27SOliver-Rainer Wittmann                 eContext = EnumContext::Context_DrawText;
54*03e5ec27SOliver-Rainer Wittmann             }
55*03e5ec27SOliver-Rainer Wittmann             else
56*03e5ec27SOliver-Rainer Wittmann             {
575d39f272SZheng Fan                 const sal_uInt32 nInv = pObj->GetObjInventor();
585d39f272SZheng Fan                 const sal_uInt16 nObjId = pObj->GetObjIdentifier();
595d39f272SZheng Fan                 if (nInv == SdrInventor)
605d39f272SZheng Fan                     eContext = GetContextForObjectId_SC(nObjId);
615d39f272SZheng Fan                 else if (nInv == FmFormInventor)
625d39f272SZheng Fan                     eContext = EnumContext::Context_Form;
63*03e5ec27SOliver-Rainer Wittmann             }
645d39f272SZheng Fan             break;
655d39f272SZheng Fan         }
665d39f272SZheng Fan 
675d39f272SZheng Fan         default:
685d39f272SZheng Fan         {
695d39f272SZheng Fan             // Multi selection.
705d39f272SZheng Fan             switch (GetInventorTypeFromMark(rMarkList))
715d39f272SZheng Fan             {
725d39f272SZheng Fan                 case SdrInventor:
735d39f272SZheng Fan                 {
745d39f272SZheng Fan                     const sal_uInt16 nObjId (GetObjectTypeFromMark(rMarkList));
755d39f272SZheng Fan                     if (nObjId == 0)
765d39f272SZheng Fan                         eContext = EnumContext::Context_MultiObject;
775d39f272SZheng Fan                     else
785d39f272SZheng Fan                         eContext = GetContextForObjectId_SC(nObjId);
795d39f272SZheng Fan                     break;
805d39f272SZheng Fan                 }
815d39f272SZheng Fan 
825d39f272SZheng Fan                 case FmFormInventor:
835d39f272SZheng Fan                     eContext = EnumContext::Context_Form;
845d39f272SZheng Fan                     break;
855d39f272SZheng Fan 
865d39f272SZheng Fan                 case 0:
875d39f272SZheng Fan                     eContext = EnumContext::Context_MultiObject;
885d39f272SZheng Fan                     break;
895d39f272SZheng Fan             }
905d39f272SZheng Fan         }
915d39f272SZheng Fan     }
925d39f272SZheng Fan 
935d39f272SZheng Fan     return eContext;
945d39f272SZheng Fan }
955d39f272SZheng Fan 
965d39f272SZheng Fan 
975d39f272SZheng Fan 
985d39f272SZheng Fan 
995d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD (
1005d39f272SZheng Fan     const SdrMarkList& rMarkList,
1015d39f272SZheng Fan     const bool bIsMasterPage,
1025d39f272SZheng Fan     const bool bIsHandoutPage,
1035d39f272SZheng Fan     const bool bIsNotesPage)
1045d39f272SZheng Fan {
1055d39f272SZheng Fan     EnumContext::Context eContext = EnumContext::Context_Unknown;
1065d39f272SZheng Fan 
1075d39f272SZheng Fan     // Note that some cases are handled by the caller.  They rely on
1085d39f272SZheng Fan     // sd specific data.
1095d39f272SZheng Fan     switch (rMarkList.GetMarkCount())
1105d39f272SZheng Fan     {
1115d39f272SZheng Fan         case 0:
1125d39f272SZheng Fan             if (bIsHandoutPage)
1135d39f272SZheng Fan                 eContext = EnumContext::Context_HandoutPage;
1145d39f272SZheng Fan             else if (bIsNotesPage)
1155d39f272SZheng Fan                 eContext = EnumContext::Context_NotesPage;
1165d39f272SZheng Fan             else if (bIsMasterPage)
1175d39f272SZheng Fan                 eContext = EnumContext::Context_MasterPage;
1185d39f272SZheng Fan             else
1195d39f272SZheng Fan                 eContext = EnumContext::Context_DrawPage;
1205d39f272SZheng Fan             break;
1215d39f272SZheng Fan 
1225d39f272SZheng Fan         case 1:
1235d39f272SZheng Fan         {
1245d39f272SZheng Fan             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
125*03e5ec27SOliver-Rainer Wittmann             if ( pObj->ISA(SdrTextObj) && ((SdrTextObj*)pObj)->IsInEditMode() )
126*03e5ec27SOliver-Rainer Wittmann             {
127*03e5ec27SOliver-Rainer Wittmann                 eContext = EnumContext::Context_DrawText;
128*03e5ec27SOliver-Rainer Wittmann             }
129*03e5ec27SOliver-Rainer Wittmann             else
130*03e5ec27SOliver-Rainer Wittmann             {
1315d39f272SZheng Fan                 const sal_uInt32 nInv = pObj->GetObjInventor();
1325d39f272SZheng Fan                 sal_uInt16 nObjId = pObj->GetObjIdentifier();
1335d39f272SZheng Fan                 if (nInv == SdrInventor)
1345d39f272SZheng Fan                 {
1355d39f272SZheng Fan                     if (nObjId == OBJ_GRUP)
1365d39f272SZheng Fan                     {
1375d39f272SZheng Fan                         nObjId = GetObjectTypeFromGroup(pObj);
1385d39f272SZheng Fan                         if (nObjId == 0)
1395d39f272SZheng Fan                             nObjId = OBJ_GRUP;
1405d39f272SZheng Fan                     }
1415d39f272SZheng Fan                     eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage);
1425d39f272SZheng Fan                 }
1435d39f272SZheng Fan                 else if (nInv == E3dInventor)
1445d39f272SZheng Fan                 {
1455d39f272SZheng Fan                     eContext = EnumContext::Context_3DObject;
1465d39f272SZheng Fan                 }
1475d39f272SZheng Fan                 else if (nInv == FmFormInventor)
1485d39f272SZheng Fan                 {
1495d39f272SZheng Fan                     eContext = EnumContext::Context_Form;
1505d39f272SZheng Fan                 }
151*03e5ec27SOliver-Rainer Wittmann             }
1525d39f272SZheng Fan             break;
1535d39f272SZheng Fan         }
1545d39f272SZheng Fan 
1555d39f272SZheng Fan         default:
1565d39f272SZheng Fan         {
1575d39f272SZheng Fan             switch (GetInventorTypeFromMark(rMarkList))
1585d39f272SZheng Fan             {
1595d39f272SZheng Fan                 case SdrInventor:
1605d39f272SZheng Fan                 {
1615d39f272SZheng Fan                     const sal_uInt16 nObjId = GetObjectTypeFromMark(rMarkList);
1625d39f272SZheng Fan                     if (nObjId == 0)
1635d39f272SZheng Fan                         eContext = EnumContext::Context_MultiObject;
1645d39f272SZheng Fan                     else
1655d39f272SZheng Fan                         eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage);
1665d39f272SZheng Fan                     break;
1675d39f272SZheng Fan                 }
1685d39f272SZheng Fan 
1695d39f272SZheng Fan                 case E3dInventor:
1705d39f272SZheng Fan                     eContext = EnumContext::Context_3DObject;
1715d39f272SZheng Fan                     break;
1725d39f272SZheng Fan 
1735d39f272SZheng Fan                 case FmFormInventor:
1745d39f272SZheng Fan                     eContext = EnumContext::Context_Form;
1755d39f272SZheng Fan                     break;
1765d39f272SZheng Fan 
1775d39f272SZheng Fan                 case 0:
1785d39f272SZheng Fan                     eContext = EnumContext::Context_MultiObject;
1795d39f272SZheng Fan                     break;
1805d39f272SZheng Fan             }
1815d39f272SZheng Fan             break;
1825d39f272SZheng Fan         }
1835d39f272SZheng Fan     }
1845d39f272SZheng Fan 
1855d39f272SZheng Fan 	return eContext;
1865d39f272SZheng Fan }
1875d39f272SZheng Fan 
1885d39f272SZheng Fan 
1895d39f272SZheng Fan 
1905d39f272SZheng Fan 
1915d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SC (const sal_uInt16 nObjectId)
1925d39f272SZheng Fan {
1935d39f272SZheng Fan     switch (nObjectId)
1945d39f272SZheng Fan     {
1955d39f272SZheng Fan         case OBJ_CAPTION:
1965d39f272SZheng Fan         case OBJ_TITLETEXT:
1975d39f272SZheng Fan         case OBJ_OUTLINETEXT:
1985d39f272SZheng Fan         case OBJ_TEXT:
1995d39f272SZheng Fan         case OBJ_TEXTEXT:
2005d39f272SZheng Fan         case OBJ_PATHLINE:
2015d39f272SZheng Fan         case OBJ_PLIN:
2025d39f272SZheng Fan         case OBJ_FREELINE:
2035d39f272SZheng Fan         case OBJ_EDGE:
2045d39f272SZheng Fan         case OBJ_LINE:
2055d39f272SZheng Fan         case OBJ_MEASURE:
2065d39f272SZheng Fan         case OBJ_RECT:
2075d39f272SZheng Fan         case OBJ_CIRC:
2085d39f272SZheng Fan         case OBJ_FREEFILL:
2095d39f272SZheng Fan         case OBJ_PATHFILL:
2105d39f272SZheng Fan         case OBJ_POLY:
2115d39f272SZheng Fan         case OBJ_SECT:
2125d39f272SZheng Fan         case OBJ_CARC:
2135d39f272SZheng Fan         case OBJ_CCUT:
2145d39f272SZheng Fan         case OBJ_CUSTOMSHAPE:
2155d39f272SZheng Fan         case OBJ_GRUP:
2165d39f272SZheng Fan             return EnumContext::Context_Draw;
2175d39f272SZheng Fan 
2185d39f272SZheng Fan         case OBJ_GRAF:
2195d39f272SZheng Fan             return EnumContext::Context_Graphic;
2205d39f272SZheng Fan 
2215d39f272SZheng Fan         case OBJ_OLE2:
2225d39f272SZheng Fan             return EnumContext::Context_OLE;
2235d39f272SZheng Fan 
2245d39f272SZheng Fan         case OBJ_MEDIA:
2255d39f272SZheng Fan             return EnumContext::Context_Media;
2265d39f272SZheng Fan             break;
2275d39f272SZheng Fan 
2285d39f272SZheng Fan         default:
2295d39f272SZheng Fan             return EnumContext::Context_Unknown;
2305d39f272SZheng Fan     }
2315d39f272SZheng Fan }
2325d39f272SZheng Fan 
2335d39f272SZheng Fan 
2345d39f272SZheng Fan 
2355d39f272SZheng Fan 
2365d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SD (
2375d39f272SZheng Fan     const sal_uInt16 nObjectId,
2385d39f272SZheng Fan     const bool bIsHandoutPage,
2395d39f272SZheng Fan     const bool bIsNotesPage)
2405d39f272SZheng Fan {
2415d39f272SZheng Fan 	switch (nObjectId)
2425d39f272SZheng Fan 	{
2435d39f272SZheng Fan 		case OBJ_CAPTION:
2445d39f272SZheng Fan 		case OBJ_PATHLINE:
2455d39f272SZheng Fan 		case OBJ_PLIN:
2465d39f272SZheng Fan 		case OBJ_FREELINE:
2475d39f272SZheng Fan 		case OBJ_EDGE:
2485d39f272SZheng Fan 		case OBJ_LINE:
2495d39f272SZheng Fan 		case OBJ_MEASURE:
2505d39f272SZheng Fan 		case OBJ_RECT:
2515d39f272SZheng Fan 		case OBJ_CIRC:
2525d39f272SZheng Fan 		case OBJ_FREEFILL:
2535d39f272SZheng Fan 		case OBJ_PATHFILL:
2545d39f272SZheng Fan 		case OBJ_POLY:
2555d39f272SZheng Fan 		case OBJ_SECT:
2565d39f272SZheng Fan 		case OBJ_CARC:
2575d39f272SZheng Fan 		case OBJ_CCUT:
2585d39f272SZheng Fan 		case OBJ_CUSTOMSHAPE:
2595d39f272SZheng Fan 		case OBJ_GRUP:
2605d39f272SZheng Fan 			return EnumContext::Context_Draw;
2615d39f272SZheng Fan 
2625d39f272SZheng Fan 		case OBJ_TITLETEXT:
2635d39f272SZheng Fan 		case OBJ_OUTLINETEXT:
2645d39f272SZheng Fan 		case OBJ_TEXT:
2655d39f272SZheng Fan 		case OBJ_TEXTEXT:
2665d39f272SZheng Fan 			return EnumContext::Context_TextObject;
2675d39f272SZheng Fan 
2685d39f272SZheng Fan 		case OBJ_GRAF:
2695d39f272SZheng Fan 			return EnumContext::Context_Graphic;
2705d39f272SZheng Fan 
2715d39f272SZheng Fan 		case OBJ_OLE2:
2725d39f272SZheng Fan 			return EnumContext::Context_OLE;
2735d39f272SZheng Fan 
2745d39f272SZheng Fan 		case OBJ_MEDIA:
2755d39f272SZheng Fan 			return EnumContext::Context_Media;
2765d39f272SZheng Fan 
2775d39f272SZheng Fan 		case OBJ_TABLE:
2785d39f272SZheng Fan 			return EnumContext::Context_Table;
2795d39f272SZheng Fan 
2805d39f272SZheng Fan 		case OBJ_PAGE:
2815d39f272SZheng Fan             if (bIsHandoutPage)
2825d39f272SZheng Fan 				return EnumContext::Context_HandoutPage;
2835d39f272SZheng Fan             else if (bIsNotesPage)
2845d39f272SZheng Fan 				return EnumContext::Context_NotesPage;
2855d39f272SZheng Fan 			else
2865d39f272SZheng Fan                 return EnumContext::Context_Unknown;
2875d39f272SZheng Fan 
2885d39f272SZheng Fan         default:
2895d39f272SZheng Fan             return EnumContext::Context_Unknown;
2905d39f272SZheng Fan 	}
2915d39f272SZheng Fan }
2925d39f272SZheng Fan 
2935d39f272SZheng Fan 
2945d39f272SZheng Fan 
2955d39f272SZheng Fan 
2965d39f272SZheng Fan sal_uInt32 SelectionAnalyzer::GetInventorTypeFromMark (const SdrMarkList& rMarkList)
2975d39f272SZheng Fan {
2985d39f272SZheng Fan     const sal_uLong nMarkCount (rMarkList.GetMarkCount());
2995d39f272SZheng Fan 
3005d39f272SZheng Fan     if (nMarkCount < 1)
3015d39f272SZheng Fan         return 0;
3025d39f272SZheng Fan 
3035d39f272SZheng Fan     SdrMark* pMark = rMarkList.GetMark(0);
3045d39f272SZheng Fan     SdrObject* pObj = pMark->GetMarkedSdrObj();
3055d39f272SZheng Fan     const sal_uInt32 nFirstInv = pObj->GetObjInventor();
3065d39f272SZheng Fan 
3075d39f272SZheng Fan     for (sal_uLong nIndex=1; nIndex<nMarkCount; ++nIndex)
3085d39f272SZheng Fan     {
3095d39f272SZheng Fan         pMark = rMarkList.GetMark(nIndex);
3105d39f272SZheng Fan         pObj = pMark->GetMarkedSdrObj();
3115d39f272SZheng Fan         const sal_uInt32 nInv (pObj->GetObjInventor());
3125d39f272SZheng Fan 
3135d39f272SZheng Fan         if (nInv != nFirstInv)
3145d39f272SZheng Fan             return 0;
3155d39f272SZheng Fan     }
3165d39f272SZheng Fan 
3175d39f272SZheng Fan     return nFirstInv;
3185d39f272SZheng Fan }
3195d39f272SZheng Fan 
3205d39f272SZheng Fan 
3215d39f272SZheng Fan 
3225d39f272SZheng Fan 
3235d39f272SZheng Fan sal_uInt16 SelectionAnalyzer::GetObjectTypeFromGroup (const SdrObject* pObj)
3245d39f272SZheng Fan {
3255d39f272SZheng Fan     SdrObjList* pObjList = pObj->GetSubList();
3265d39f272SZheng Fan     if (pObjList)
3275d39f272SZheng Fan     {
3285d39f272SZheng Fan         const sal_uLong nSubObjCount (pObjList->GetObjCount());
3295d39f272SZheng Fan 
3305d39f272SZheng Fan         if (nSubObjCount>0)
3315d39f272SZheng Fan         {
3325d39f272SZheng Fan             SdrObject* pObj = pObjList->GetObj(0);
3335d39f272SZheng Fan             sal_uInt16 nResultType = pObj->GetObjIdentifier();
3345d39f272SZheng Fan 
3355d39f272SZheng Fan             if (nResultType == OBJ_GRUP)
3365d39f272SZheng Fan                 nResultType = GetObjectTypeFromGroup(pObj);
3375d39f272SZheng Fan 
3385d39f272SZheng Fan             if (IsShapeType(nResultType))
3395d39f272SZheng Fan                 nResultType = OBJ_CUSTOMSHAPE;
3405d39f272SZheng Fan 
3415d39f272SZheng Fan             if (IsTextObjType(nResultType))
3425d39f272SZheng Fan                 nResultType = OBJ_TEXT;
3435d39f272SZheng Fan 
3445d39f272SZheng Fan             for (sal_uInt16 nIndex=1; nIndex<nSubObjCount; ++nIndex)
3455d39f272SZheng Fan             {
3465d39f272SZheng Fan                 pObj = pObjList->GetObj(nIndex);
3475d39f272SZheng Fan                 sal_uInt16 nType (pObj->GetObjIdentifier());
3485d39f272SZheng Fan 
3495d39f272SZheng Fan                 if(nType == OBJ_GRUP)
3505d39f272SZheng Fan                     nType = GetObjectTypeFromGroup(pObj);
3515d39f272SZheng Fan 
3525d39f272SZheng Fan                 if (IsShapeType(nType))
3535d39f272SZheng Fan                     nType = OBJ_CUSTOMSHAPE;
3545d39f272SZheng Fan 
3555d39f272SZheng Fan                 if ((nType == OBJ_CUSTOMSHAPE) && (nResultType == OBJ_TEXT))
3565d39f272SZheng Fan                     nType = OBJ_TEXT;
3575d39f272SZheng Fan 
3585d39f272SZheng Fan                 if (IsTextObjType(nType))
3595d39f272SZheng Fan                     nType = OBJ_TEXT;
3605d39f272SZheng Fan 
3615d39f272SZheng Fan                 if ((nType == OBJ_TEXT) && (nResultType == OBJ_CUSTOMSHAPE))
3625d39f272SZheng Fan                     nResultType = OBJ_TEXT;
3635d39f272SZheng Fan 
3645d39f272SZheng Fan                 if (nType != nResultType)
3655d39f272SZheng Fan                     return 0;
3665d39f272SZheng Fan             }
3675d39f272SZheng Fan 
3685d39f272SZheng Fan             return nResultType;
3695d39f272SZheng Fan         }
3705d39f272SZheng Fan     }
3715d39f272SZheng Fan 
3725d39f272SZheng Fan     return 0;
3735d39f272SZheng Fan }
3745d39f272SZheng Fan 
3755d39f272SZheng Fan 
3765d39f272SZheng Fan 
3775d39f272SZheng Fan 
3785d39f272SZheng Fan sal_uInt16  SelectionAnalyzer::GetObjectTypeFromMark (const SdrMarkList& rMarkList)
3795d39f272SZheng Fan {
3805d39f272SZheng Fan     const sal_uLong nMarkCount (rMarkList.GetMarkCount());
3815d39f272SZheng Fan 
3825d39f272SZheng Fan     if (nMarkCount < 1)
3835d39f272SZheng Fan         return 0;
3845d39f272SZheng Fan 
3855d39f272SZheng Fan     SdrMark* pMark = rMarkList.GetMark(0);
3865d39f272SZheng Fan     SdrObject* pObj = pMark->GetMarkedSdrObj();
3875d39f272SZheng Fan     sal_uInt16 nResultType = pObj->GetObjIdentifier();
3885d39f272SZheng Fan 
3895d39f272SZheng Fan     if(nResultType == OBJ_GRUP)
3905d39f272SZheng Fan         nResultType = GetObjectTypeFromGroup(pObj);
3915d39f272SZheng Fan 
3925d39f272SZheng Fan     if (IsShapeType(nResultType))
3935d39f272SZheng Fan         nResultType = OBJ_CUSTOMSHAPE;
3945d39f272SZheng Fan 
3955d39f272SZheng Fan     if (IsTextObjType(nResultType))
3965d39f272SZheng Fan         nResultType = OBJ_TEXT;
3975d39f272SZheng Fan 
3985d39f272SZheng Fan     for (sal_uLong nIndex=1; nIndex<nMarkCount; ++nIndex)
3995d39f272SZheng Fan     {
4005d39f272SZheng Fan         pMark = rMarkList.GetMark(nIndex);
4015d39f272SZheng Fan         pObj = pMark->GetMarkedSdrObj();
4025d39f272SZheng Fan         sal_uInt16 nType = pObj->GetObjIdentifier();
4035d39f272SZheng Fan 
4045d39f272SZheng Fan         if(nType == OBJ_GRUP)
4055d39f272SZheng Fan             nType = GetObjectTypeFromGroup(pObj);
4065d39f272SZheng Fan 
4075d39f272SZheng Fan         if (IsShapeType(nType))
4085d39f272SZheng Fan             nType = OBJ_CUSTOMSHAPE;
4095d39f272SZheng Fan 
4105d39f272SZheng Fan         if ((nType == OBJ_CUSTOMSHAPE) && (nResultType == OBJ_TEXT))
4115d39f272SZheng Fan             nType = OBJ_TEXT;
4125d39f272SZheng Fan 
4135d39f272SZheng Fan         if (IsTextObjType(nType))
4145d39f272SZheng Fan             nType = OBJ_TEXT;
4155d39f272SZheng Fan 
4165d39f272SZheng Fan         if ((nType == OBJ_TEXT) && (nResultType == OBJ_CUSTOMSHAPE))
4175d39f272SZheng Fan             nResultType = OBJ_TEXT;
4185d39f272SZheng Fan 
4195d39f272SZheng Fan         if (nType != nResultType)
4205d39f272SZheng Fan             return 0;
4215d39f272SZheng Fan     }
4225d39f272SZheng Fan 
4235d39f272SZheng Fan     return nResultType;
4245d39f272SZheng Fan }
4255d39f272SZheng Fan 
4265d39f272SZheng Fan 
4275d39f272SZheng Fan 
4285d39f272SZheng Fan 
4295d39f272SZheng Fan bool SelectionAnalyzer::IsShapeType (const sal_uInt16 nType)
4305d39f272SZheng Fan {
4315d39f272SZheng Fan 	switch (nType)
4325d39f272SZheng Fan     {
4335d39f272SZheng Fan 		case OBJ_LINE:
4345d39f272SZheng Fan 		case OBJ_CARC:
4355d39f272SZheng Fan 		case OBJ_PLIN:
4365d39f272SZheng Fan 		case OBJ_PATHLINE:
4375d39f272SZheng Fan 		case OBJ_RECT:
4385d39f272SZheng Fan 		case OBJ_CIRC:
4395d39f272SZheng Fan 		case OBJ_SECT:
4405d39f272SZheng Fan 		case OBJ_CCUT:
4415d39f272SZheng Fan 		case OBJ_PATHFILL:
4425d39f272SZheng Fan 		case OBJ_CUSTOMSHAPE:
4435d39f272SZheng Fan 		case OBJ_CAPTION:
4445d39f272SZheng Fan 		case OBJ_MEASURE:
4455d39f272SZheng Fan 		case OBJ_EDGE:
4465d39f272SZheng Fan 		case OBJ_POLY:
4475d39f272SZheng Fan 		case OBJ_FREELINE:
4485d39f272SZheng Fan 		case OBJ_FREEFILL:
4495d39f272SZheng Fan 			return true;
4505d39f272SZheng Fan 
4515d39f272SZheng Fan 		default:
4525d39f272SZheng Fan             return false;
4535d39f272SZheng Fan 	}
4545d39f272SZheng Fan }
4555d39f272SZheng Fan 
4565d39f272SZheng Fan 
4575d39f272SZheng Fan 
4585d39f272SZheng Fan 
4595d39f272SZheng Fan bool SelectionAnalyzer::IsTextObjType (const sal_uInt16 nType)
4605d39f272SZheng Fan {
4615d39f272SZheng Fan 	switch(nType)
4625d39f272SZheng Fan     {
4635d39f272SZheng Fan 		case OBJ_TEXT:
4645d39f272SZheng Fan 		case OBJ_TEXTEXT:
4655d39f272SZheng Fan 		case OBJ_TITLETEXT:
4665d39f272SZheng Fan 		case OBJ_OUTLINETEXT:
4675d39f272SZheng Fan 			return true;
4685d39f272SZheng Fan 
4695d39f272SZheng Fan 		default:
4705d39f272SZheng Fan             return false;
4715d39f272SZheng Fan 	}
4725d39f272SZheng Fan }
4735d39f272SZheng Fan 
4745d39f272SZheng Fan 
4755d39f272SZheng Fan 
4765d39f272SZheng Fan } } // end of namespace ::svx::sidebar
477