xref: /AOO41X/main/svx/source/sidebar/SelectionAnalyzer.cxx (revision 5d39f272d9084beebffa455156ddd8913c39a8d6)
1*5d39f272SZheng Fan /**************************************************************
2*5d39f272SZheng Fan  *
3*5d39f272SZheng Fan  * Licensed to the Apache Software Foundation (ASF) under one
4*5d39f272SZheng Fan  * or more contributor license agreements.  See the NOTICE file
5*5d39f272SZheng Fan  * distributed with this work for additional information
6*5d39f272SZheng Fan  * regarding copyright ownership.  The ASF licenses this file
7*5d39f272SZheng Fan  * to you under the Apache License, Version 2.0 (the
8*5d39f272SZheng Fan  * "License"); you may not use this file except in compliance
9*5d39f272SZheng Fan  * with the License.  You may obtain a copy of the License at
10*5d39f272SZheng Fan  *
11*5d39f272SZheng Fan  *   http://www.apache.org/licenses/LICENSE-2.0
12*5d39f272SZheng Fan  *
13*5d39f272SZheng Fan  * Unless required by applicable law or agreed to in writing,
14*5d39f272SZheng Fan  * software distributed under the License is distributed on an
15*5d39f272SZheng Fan  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5d39f272SZheng Fan  * KIND, either express or implied.  See the License for the
17*5d39f272SZheng Fan  * specific language governing permissions and limitations
18*5d39f272SZheng Fan  * under the License.
19*5d39f272SZheng Fan  *
20*5d39f272SZheng Fan  *************************************************************/
21*5d39f272SZheng Fan 
22*5d39f272SZheng Fan #include "precompiled_svx.hxx"
23*5d39f272SZheng Fan 
24*5d39f272SZheng Fan #include "svx/sidebar/SelectionAnalyzer.hxx"
25*5d39f272SZheng Fan #include "svx/svdmrkv.hxx"
26*5d39f272SZheng Fan #include "svx/svdobj.hxx"
27*5d39f272SZheng Fan #include "svx/svdpage.hxx"
28*5d39f272SZheng Fan #include "svx/fmglob.hxx"
29*5d39f272SZheng Fan #include "svx/globl3d.hxx"
30*5d39f272SZheng Fan 
31*5d39f272SZheng Fan using sfx2::sidebar::EnumContext;
32*5d39f272SZheng Fan 
33*5d39f272SZheng Fan 
34*5d39f272SZheng Fan namespace svx { namespace sidebar {
35*5d39f272SZheng Fan 
36*5d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForSelection_SC (const SdrMarkList& rMarkList)
37*5d39f272SZheng Fan {
38*5d39f272SZheng Fan     EnumContext::Context eContext = EnumContext::Context_Unknown;
39*5d39f272SZheng Fan 
40*5d39f272SZheng Fan     switch (rMarkList.GetMarkCount())
41*5d39f272SZheng Fan     {
42*5d39f272SZheng Fan         case 0:
43*5d39f272SZheng Fan             // Empty selection.  Return Context_Unknown to let the caller
44*5d39f272SZheng Fan             // substitute it with the default context.
45*5d39f272SZheng Fan             break;
46*5d39f272SZheng Fan 
47*5d39f272SZheng Fan         case 1:
48*5d39f272SZheng Fan         {
49*5d39f272SZheng Fan             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
50*5d39f272SZheng Fan             const sal_uInt32 nInv = pObj->GetObjInventor();
51*5d39f272SZheng Fan             const sal_uInt16 nObjId = pObj->GetObjIdentifier();
52*5d39f272SZheng Fan             if (nInv == SdrInventor)
53*5d39f272SZheng Fan                 eContext = GetContextForObjectId_SC(nObjId);
54*5d39f272SZheng Fan             else if (nInv == FmFormInventor)
55*5d39f272SZheng Fan                 eContext = EnumContext::Context_Form;
56*5d39f272SZheng Fan             break;
57*5d39f272SZheng Fan         }
58*5d39f272SZheng Fan 
59*5d39f272SZheng Fan         default:
60*5d39f272SZheng Fan         {
61*5d39f272SZheng Fan             // Multi selection.
62*5d39f272SZheng Fan             switch (GetInventorTypeFromMark(rMarkList))
63*5d39f272SZheng Fan             {
64*5d39f272SZheng Fan                 case SdrInventor:
65*5d39f272SZheng Fan                 {
66*5d39f272SZheng Fan                     const sal_uInt16 nObjId (GetObjectTypeFromMark(rMarkList));
67*5d39f272SZheng Fan                     if (nObjId == 0)
68*5d39f272SZheng Fan                         eContext = EnumContext::Context_MultiObject;
69*5d39f272SZheng Fan                     else
70*5d39f272SZheng Fan                         eContext = GetContextForObjectId_SC(nObjId);
71*5d39f272SZheng Fan                     break;
72*5d39f272SZheng Fan                 }
73*5d39f272SZheng Fan 
74*5d39f272SZheng Fan                 case FmFormInventor:
75*5d39f272SZheng Fan                     eContext = EnumContext::Context_Form;
76*5d39f272SZheng Fan                     break;
77*5d39f272SZheng Fan 
78*5d39f272SZheng Fan                 case 0:
79*5d39f272SZheng Fan                     eContext = EnumContext::Context_MultiObject;
80*5d39f272SZheng Fan                     break;
81*5d39f272SZheng Fan             }
82*5d39f272SZheng Fan         }
83*5d39f272SZheng Fan     }
84*5d39f272SZheng Fan 
85*5d39f272SZheng Fan     return eContext;
86*5d39f272SZheng Fan }
87*5d39f272SZheng Fan 
88*5d39f272SZheng Fan 
89*5d39f272SZheng Fan 
90*5d39f272SZheng Fan 
91*5d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForSelection_SD (
92*5d39f272SZheng Fan     const SdrMarkList& rMarkList,
93*5d39f272SZheng Fan     const bool bIsMasterPage,
94*5d39f272SZheng Fan     const bool bIsHandoutPage,
95*5d39f272SZheng Fan     const bool bIsNotesPage)
96*5d39f272SZheng Fan {
97*5d39f272SZheng Fan     EnumContext::Context eContext = EnumContext::Context_Unknown;
98*5d39f272SZheng Fan 
99*5d39f272SZheng Fan     // Note that some cases are handled by the caller.  They rely on
100*5d39f272SZheng Fan     // sd specific data.
101*5d39f272SZheng Fan     switch (rMarkList.GetMarkCount())
102*5d39f272SZheng Fan     {
103*5d39f272SZheng Fan         case 0:
104*5d39f272SZheng Fan             if (bIsHandoutPage)
105*5d39f272SZheng Fan                 eContext = EnumContext::Context_HandoutPage;
106*5d39f272SZheng Fan             else if (bIsNotesPage)
107*5d39f272SZheng Fan                 eContext = EnumContext::Context_NotesPage;
108*5d39f272SZheng Fan             else if (bIsMasterPage)
109*5d39f272SZheng Fan                 eContext = EnumContext::Context_MasterPage;
110*5d39f272SZheng Fan             else
111*5d39f272SZheng Fan                 eContext = EnumContext::Context_DrawPage;
112*5d39f272SZheng Fan             break;
113*5d39f272SZheng Fan 
114*5d39f272SZheng Fan         case 1:
115*5d39f272SZheng Fan         {
116*5d39f272SZheng Fan             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
117*5d39f272SZheng Fan             const sal_uInt32 nInv = pObj->GetObjInventor();
118*5d39f272SZheng Fan             sal_uInt16 nObjId = pObj->GetObjIdentifier();
119*5d39f272SZheng Fan             if (nInv == SdrInventor)
120*5d39f272SZheng Fan             {
121*5d39f272SZheng Fan                 if (nObjId == OBJ_GRUP)
122*5d39f272SZheng Fan                 {
123*5d39f272SZheng Fan                     nObjId = GetObjectTypeFromGroup(pObj);
124*5d39f272SZheng Fan                     if (nObjId == 0)
125*5d39f272SZheng Fan                         nObjId = OBJ_GRUP;
126*5d39f272SZheng Fan                 }
127*5d39f272SZheng Fan                 eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage);
128*5d39f272SZheng Fan             }
129*5d39f272SZheng Fan             else if (nInv == E3dInventor)
130*5d39f272SZheng Fan             {
131*5d39f272SZheng Fan                 eContext = EnumContext::Context_3DObject;
132*5d39f272SZheng Fan             }
133*5d39f272SZheng Fan             else if (nInv == FmFormInventor)
134*5d39f272SZheng Fan             {
135*5d39f272SZheng Fan                 eContext = EnumContext::Context_Form;
136*5d39f272SZheng Fan             }
137*5d39f272SZheng Fan             break;
138*5d39f272SZheng Fan         }
139*5d39f272SZheng Fan 
140*5d39f272SZheng Fan         default:
141*5d39f272SZheng Fan         {
142*5d39f272SZheng Fan             switch (GetInventorTypeFromMark(rMarkList))
143*5d39f272SZheng Fan             {
144*5d39f272SZheng Fan                 case SdrInventor:
145*5d39f272SZheng Fan                 {
146*5d39f272SZheng Fan                     const sal_uInt16 nObjId = GetObjectTypeFromMark(rMarkList);
147*5d39f272SZheng Fan                     if (nObjId == 0)
148*5d39f272SZheng Fan                         eContext = EnumContext::Context_MultiObject;
149*5d39f272SZheng Fan                     else
150*5d39f272SZheng Fan                         eContext = GetContextForObjectId_SD(nObjId, bIsHandoutPage, bIsNotesPage);
151*5d39f272SZheng Fan                     break;
152*5d39f272SZheng Fan                 }
153*5d39f272SZheng Fan 
154*5d39f272SZheng Fan                 case E3dInventor:
155*5d39f272SZheng Fan                     eContext = EnumContext::Context_3DObject;
156*5d39f272SZheng Fan                     break;
157*5d39f272SZheng Fan 
158*5d39f272SZheng Fan                 case FmFormInventor:
159*5d39f272SZheng Fan                     eContext = EnumContext::Context_Form;
160*5d39f272SZheng Fan                     break;
161*5d39f272SZheng Fan 
162*5d39f272SZheng Fan                 case 0:
163*5d39f272SZheng Fan                     eContext = EnumContext::Context_MultiObject;
164*5d39f272SZheng Fan                     break;
165*5d39f272SZheng Fan             }
166*5d39f272SZheng Fan             break;
167*5d39f272SZheng Fan         }
168*5d39f272SZheng Fan     }
169*5d39f272SZheng Fan 
170*5d39f272SZheng Fan 	return eContext;
171*5d39f272SZheng Fan }
172*5d39f272SZheng Fan 
173*5d39f272SZheng Fan 
174*5d39f272SZheng Fan 
175*5d39f272SZheng Fan 
176*5d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SC (const sal_uInt16 nObjectId)
177*5d39f272SZheng Fan {
178*5d39f272SZheng Fan     switch (nObjectId)
179*5d39f272SZheng Fan     {
180*5d39f272SZheng Fan         case OBJ_CAPTION:
181*5d39f272SZheng Fan         case OBJ_TITLETEXT:
182*5d39f272SZheng Fan         case OBJ_OUTLINETEXT:
183*5d39f272SZheng Fan         case OBJ_TEXT:
184*5d39f272SZheng Fan         case OBJ_TEXTEXT:
185*5d39f272SZheng Fan         case OBJ_PATHLINE:
186*5d39f272SZheng Fan         case OBJ_PLIN:
187*5d39f272SZheng Fan         case OBJ_FREELINE:
188*5d39f272SZheng Fan         case OBJ_EDGE:
189*5d39f272SZheng Fan         case OBJ_LINE:
190*5d39f272SZheng Fan         case OBJ_MEASURE:
191*5d39f272SZheng Fan         case OBJ_RECT:
192*5d39f272SZheng Fan         case OBJ_CIRC:
193*5d39f272SZheng Fan         case OBJ_FREEFILL:
194*5d39f272SZheng Fan         case OBJ_PATHFILL:
195*5d39f272SZheng Fan         case OBJ_POLY:
196*5d39f272SZheng Fan         case OBJ_SECT:
197*5d39f272SZheng Fan         case OBJ_CARC:
198*5d39f272SZheng Fan         case OBJ_CCUT:
199*5d39f272SZheng Fan         case OBJ_CUSTOMSHAPE:
200*5d39f272SZheng Fan         case OBJ_GRUP:
201*5d39f272SZheng Fan             return EnumContext::Context_Draw;
202*5d39f272SZheng Fan 
203*5d39f272SZheng Fan         case OBJ_GRAF:
204*5d39f272SZheng Fan             return EnumContext::Context_Graphic;
205*5d39f272SZheng Fan 
206*5d39f272SZheng Fan         case OBJ_OLE2:
207*5d39f272SZheng Fan             return EnumContext::Context_OLE;
208*5d39f272SZheng Fan 
209*5d39f272SZheng Fan         case OBJ_MEDIA:
210*5d39f272SZheng Fan             return EnumContext::Context_Media;
211*5d39f272SZheng Fan             break;
212*5d39f272SZheng Fan 
213*5d39f272SZheng Fan         default:
214*5d39f272SZheng Fan             return EnumContext::Context_Unknown;
215*5d39f272SZheng Fan     }
216*5d39f272SZheng Fan }
217*5d39f272SZheng Fan 
218*5d39f272SZheng Fan 
219*5d39f272SZheng Fan 
220*5d39f272SZheng Fan 
221*5d39f272SZheng Fan EnumContext::Context SelectionAnalyzer::GetContextForObjectId_SD (
222*5d39f272SZheng Fan     const sal_uInt16 nObjectId,
223*5d39f272SZheng Fan     const bool bIsHandoutPage,
224*5d39f272SZheng Fan     const bool bIsNotesPage)
225*5d39f272SZheng Fan {
226*5d39f272SZheng Fan 	switch (nObjectId)
227*5d39f272SZheng Fan 	{
228*5d39f272SZheng Fan 		case OBJ_CAPTION:
229*5d39f272SZheng Fan 		case OBJ_PATHLINE:
230*5d39f272SZheng Fan 		case OBJ_PLIN:
231*5d39f272SZheng Fan 		case OBJ_FREELINE:
232*5d39f272SZheng Fan 		case OBJ_EDGE:
233*5d39f272SZheng Fan 		case OBJ_LINE:
234*5d39f272SZheng Fan 		case OBJ_MEASURE:
235*5d39f272SZheng Fan 		case OBJ_RECT:
236*5d39f272SZheng Fan 		case OBJ_CIRC:
237*5d39f272SZheng Fan 		case OBJ_FREEFILL:
238*5d39f272SZheng Fan 		case OBJ_PATHFILL:
239*5d39f272SZheng Fan 		case OBJ_POLY:
240*5d39f272SZheng Fan 		case OBJ_SECT:
241*5d39f272SZheng Fan 		case OBJ_CARC:
242*5d39f272SZheng Fan 		case OBJ_CCUT:
243*5d39f272SZheng Fan 		case OBJ_CUSTOMSHAPE:
244*5d39f272SZheng Fan 		case OBJ_GRUP:
245*5d39f272SZheng Fan 			return EnumContext::Context_Draw;
246*5d39f272SZheng Fan 
247*5d39f272SZheng Fan 		case OBJ_TITLETEXT:
248*5d39f272SZheng Fan 		case OBJ_OUTLINETEXT:
249*5d39f272SZheng Fan 		case OBJ_TEXT:
250*5d39f272SZheng Fan 		case OBJ_TEXTEXT:
251*5d39f272SZheng Fan 			return EnumContext::Context_TextObject;
252*5d39f272SZheng Fan 
253*5d39f272SZheng Fan 		case OBJ_GRAF:
254*5d39f272SZheng Fan 			return EnumContext::Context_Graphic;
255*5d39f272SZheng Fan 
256*5d39f272SZheng Fan 		case OBJ_OLE2:
257*5d39f272SZheng Fan 			return EnumContext::Context_OLE;
258*5d39f272SZheng Fan 
259*5d39f272SZheng Fan 		case OBJ_MEDIA:
260*5d39f272SZheng Fan 			return EnumContext::Context_Media;
261*5d39f272SZheng Fan 
262*5d39f272SZheng Fan 		case OBJ_TABLE:
263*5d39f272SZheng Fan 			return EnumContext::Context_Table;
264*5d39f272SZheng Fan 
265*5d39f272SZheng Fan 		case OBJ_PAGE:
266*5d39f272SZheng Fan             if (bIsHandoutPage)
267*5d39f272SZheng Fan 				return EnumContext::Context_HandoutPage;
268*5d39f272SZheng Fan             else if (bIsNotesPage)
269*5d39f272SZheng Fan 				return EnumContext::Context_NotesPage;
270*5d39f272SZheng Fan 			else
271*5d39f272SZheng Fan                 return EnumContext::Context_Unknown;
272*5d39f272SZheng Fan 
273*5d39f272SZheng Fan         default:
274*5d39f272SZheng Fan             return EnumContext::Context_Unknown;
275*5d39f272SZheng Fan 	}
276*5d39f272SZheng Fan }
277*5d39f272SZheng Fan 
278*5d39f272SZheng Fan 
279*5d39f272SZheng Fan 
280*5d39f272SZheng Fan 
281*5d39f272SZheng Fan sal_uInt32 SelectionAnalyzer::GetInventorTypeFromMark (const SdrMarkList& rMarkList)
282*5d39f272SZheng Fan {
283*5d39f272SZheng Fan     const sal_uLong nMarkCount (rMarkList.GetMarkCount());
284*5d39f272SZheng Fan 
285*5d39f272SZheng Fan     if (nMarkCount < 1)
286*5d39f272SZheng Fan         return 0;
287*5d39f272SZheng Fan 
288*5d39f272SZheng Fan     SdrMark* pMark = rMarkList.GetMark(0);
289*5d39f272SZheng Fan     SdrObject* pObj = pMark->GetMarkedSdrObj();
290*5d39f272SZheng Fan     const sal_uInt32 nFirstInv = pObj->GetObjInventor();
291*5d39f272SZheng Fan 
292*5d39f272SZheng Fan     for (sal_uLong nIndex=1; nIndex<nMarkCount; ++nIndex)
293*5d39f272SZheng Fan     {
294*5d39f272SZheng Fan         pMark = rMarkList.GetMark(nIndex);
295*5d39f272SZheng Fan         pObj = pMark->GetMarkedSdrObj();
296*5d39f272SZheng Fan         const sal_uInt32 nInv (pObj->GetObjInventor());
297*5d39f272SZheng Fan 
298*5d39f272SZheng Fan         if (nInv != nFirstInv)
299*5d39f272SZheng Fan             return 0;
300*5d39f272SZheng Fan     }
301*5d39f272SZheng Fan 
302*5d39f272SZheng Fan     return nFirstInv;
303*5d39f272SZheng Fan }
304*5d39f272SZheng Fan 
305*5d39f272SZheng Fan 
306*5d39f272SZheng Fan 
307*5d39f272SZheng Fan 
308*5d39f272SZheng Fan sal_uInt16 SelectionAnalyzer::GetObjectTypeFromGroup (const SdrObject* pObj)
309*5d39f272SZheng Fan {
310*5d39f272SZheng Fan     SdrObjList* pObjList = pObj->GetSubList();
311*5d39f272SZheng Fan     if (pObjList)
312*5d39f272SZheng Fan     {
313*5d39f272SZheng Fan         const sal_uLong nSubObjCount (pObjList->GetObjCount());
314*5d39f272SZheng Fan 
315*5d39f272SZheng Fan         if (nSubObjCount>0)
316*5d39f272SZheng Fan         {
317*5d39f272SZheng Fan             SdrObject* pObj = pObjList->GetObj(0);
318*5d39f272SZheng Fan             sal_uInt16 nResultType = pObj->GetObjIdentifier();
319*5d39f272SZheng Fan 
320*5d39f272SZheng Fan             if (nResultType == OBJ_GRUP)
321*5d39f272SZheng Fan                 nResultType = GetObjectTypeFromGroup(pObj);
322*5d39f272SZheng Fan 
323*5d39f272SZheng Fan             if (IsShapeType(nResultType))
324*5d39f272SZheng Fan                 nResultType = OBJ_CUSTOMSHAPE;
325*5d39f272SZheng Fan 
326*5d39f272SZheng Fan             if (IsTextObjType(nResultType))
327*5d39f272SZheng Fan                 nResultType = OBJ_TEXT;
328*5d39f272SZheng Fan 
329*5d39f272SZheng Fan             for (sal_uInt16 nIndex=1; nIndex<nSubObjCount; ++nIndex)
330*5d39f272SZheng Fan             {
331*5d39f272SZheng Fan                 pObj = pObjList->GetObj(nIndex);
332*5d39f272SZheng Fan                 sal_uInt16 nType (pObj->GetObjIdentifier());
333*5d39f272SZheng Fan 
334*5d39f272SZheng Fan                 if(nType == OBJ_GRUP)
335*5d39f272SZheng Fan                     nType = GetObjectTypeFromGroup(pObj);
336*5d39f272SZheng Fan 
337*5d39f272SZheng Fan                 if (IsShapeType(nType))
338*5d39f272SZheng Fan                     nType = OBJ_CUSTOMSHAPE;
339*5d39f272SZheng Fan 
340*5d39f272SZheng Fan                 if ((nType == OBJ_CUSTOMSHAPE) && (nResultType == OBJ_TEXT))
341*5d39f272SZheng Fan                     nType = OBJ_TEXT;
342*5d39f272SZheng Fan 
343*5d39f272SZheng Fan                 if (IsTextObjType(nType))
344*5d39f272SZheng Fan                     nType = OBJ_TEXT;
345*5d39f272SZheng Fan 
346*5d39f272SZheng Fan                 if ((nType == OBJ_TEXT) && (nResultType == OBJ_CUSTOMSHAPE))
347*5d39f272SZheng Fan                     nResultType = OBJ_TEXT;
348*5d39f272SZheng Fan 
349*5d39f272SZheng Fan                 if (nType != nResultType)
350*5d39f272SZheng Fan                     return 0;
351*5d39f272SZheng Fan             }
352*5d39f272SZheng Fan 
353*5d39f272SZheng Fan             return nResultType;
354*5d39f272SZheng Fan         }
355*5d39f272SZheng Fan     }
356*5d39f272SZheng Fan 
357*5d39f272SZheng Fan     return 0;
358*5d39f272SZheng Fan }
359*5d39f272SZheng Fan 
360*5d39f272SZheng Fan 
361*5d39f272SZheng Fan 
362*5d39f272SZheng Fan 
363*5d39f272SZheng Fan sal_uInt16  SelectionAnalyzer::GetObjectTypeFromMark (const SdrMarkList& rMarkList)
364*5d39f272SZheng Fan {
365*5d39f272SZheng Fan     const sal_uLong nMarkCount (rMarkList.GetMarkCount());
366*5d39f272SZheng Fan 
367*5d39f272SZheng Fan     if (nMarkCount < 1)
368*5d39f272SZheng Fan         return 0;
369*5d39f272SZheng Fan 
370*5d39f272SZheng Fan     SdrMark* pMark = rMarkList.GetMark(0);
371*5d39f272SZheng Fan     SdrObject* pObj = pMark->GetMarkedSdrObj();
372*5d39f272SZheng Fan     sal_uInt16 nResultType = pObj->GetObjIdentifier();
373*5d39f272SZheng Fan 
374*5d39f272SZheng Fan     if(nResultType == OBJ_GRUP)
375*5d39f272SZheng Fan         nResultType = GetObjectTypeFromGroup(pObj);
376*5d39f272SZheng Fan 
377*5d39f272SZheng Fan     if (IsShapeType(nResultType))
378*5d39f272SZheng Fan         nResultType = OBJ_CUSTOMSHAPE;
379*5d39f272SZheng Fan 
380*5d39f272SZheng Fan     if (IsTextObjType(nResultType))
381*5d39f272SZheng Fan         nResultType = OBJ_TEXT;
382*5d39f272SZheng Fan 
383*5d39f272SZheng Fan     for (sal_uLong nIndex=1; nIndex<nMarkCount; ++nIndex)
384*5d39f272SZheng Fan     {
385*5d39f272SZheng Fan         pMark = rMarkList.GetMark(nIndex);
386*5d39f272SZheng Fan         pObj = pMark->GetMarkedSdrObj();
387*5d39f272SZheng Fan         sal_uInt16 nType = pObj->GetObjIdentifier();
388*5d39f272SZheng Fan 
389*5d39f272SZheng Fan         if(nType == OBJ_GRUP)
390*5d39f272SZheng Fan             nType = GetObjectTypeFromGroup(pObj);
391*5d39f272SZheng Fan 
392*5d39f272SZheng Fan         if (IsShapeType(nType))
393*5d39f272SZheng Fan             nType = OBJ_CUSTOMSHAPE;
394*5d39f272SZheng Fan 
395*5d39f272SZheng Fan         if ((nType == OBJ_CUSTOMSHAPE) && (nResultType == OBJ_TEXT))
396*5d39f272SZheng Fan             nType = OBJ_TEXT;
397*5d39f272SZheng Fan 
398*5d39f272SZheng Fan         if (IsTextObjType(nType))
399*5d39f272SZheng Fan             nType = OBJ_TEXT;
400*5d39f272SZheng Fan 
401*5d39f272SZheng Fan         if ((nType == OBJ_TEXT) && (nResultType == OBJ_CUSTOMSHAPE))
402*5d39f272SZheng Fan             nResultType = OBJ_TEXT;
403*5d39f272SZheng Fan 
404*5d39f272SZheng Fan         if (nType != nResultType)
405*5d39f272SZheng Fan             return 0;
406*5d39f272SZheng Fan     }
407*5d39f272SZheng Fan 
408*5d39f272SZheng Fan     return nResultType;
409*5d39f272SZheng Fan }
410*5d39f272SZheng Fan 
411*5d39f272SZheng Fan 
412*5d39f272SZheng Fan 
413*5d39f272SZheng Fan 
414*5d39f272SZheng Fan bool SelectionAnalyzer::IsShapeType (const sal_uInt16 nType)
415*5d39f272SZheng Fan {
416*5d39f272SZheng Fan 	switch (nType)
417*5d39f272SZheng Fan     {
418*5d39f272SZheng Fan 		case OBJ_LINE:
419*5d39f272SZheng Fan 		case OBJ_CARC:
420*5d39f272SZheng Fan 		case OBJ_PLIN:
421*5d39f272SZheng Fan 		case OBJ_PATHLINE:
422*5d39f272SZheng Fan 		case OBJ_RECT:
423*5d39f272SZheng Fan 		case OBJ_CIRC:
424*5d39f272SZheng Fan 		case OBJ_SECT:
425*5d39f272SZheng Fan 		case OBJ_CCUT:
426*5d39f272SZheng Fan 		case OBJ_PATHFILL:
427*5d39f272SZheng Fan 		case OBJ_CUSTOMSHAPE:
428*5d39f272SZheng Fan 		case OBJ_CAPTION:
429*5d39f272SZheng Fan 		case OBJ_MEASURE:
430*5d39f272SZheng Fan 		case OBJ_EDGE:
431*5d39f272SZheng Fan 		case OBJ_POLY:
432*5d39f272SZheng Fan 		case OBJ_FREELINE:
433*5d39f272SZheng Fan 		case OBJ_FREEFILL:
434*5d39f272SZheng Fan 			return true;
435*5d39f272SZheng Fan 
436*5d39f272SZheng Fan 		default:
437*5d39f272SZheng Fan             return false;
438*5d39f272SZheng Fan 	}
439*5d39f272SZheng Fan }
440*5d39f272SZheng Fan 
441*5d39f272SZheng Fan 
442*5d39f272SZheng Fan 
443*5d39f272SZheng Fan 
444*5d39f272SZheng Fan bool SelectionAnalyzer::IsTextObjType (const sal_uInt16 nType)
445*5d39f272SZheng Fan {
446*5d39f272SZheng Fan 	switch(nType)
447*5d39f272SZheng Fan     {
448*5d39f272SZheng Fan 		case OBJ_TEXT:
449*5d39f272SZheng Fan 		case OBJ_TEXTEXT:
450*5d39f272SZheng Fan 		case OBJ_TITLETEXT:
451*5d39f272SZheng Fan 		case OBJ_OUTLINETEXT:
452*5d39f272SZheng Fan 			return true;
453*5d39f272SZheng Fan 
454*5d39f272SZheng Fan 		default:
455*5d39f272SZheng Fan             return false;
456*5d39f272SZheng Fan 	}
457*5d39f272SZheng Fan }
458*5d39f272SZheng Fan 
459*5d39f272SZheng Fan 
460*5d39f272SZheng Fan 
461*5d39f272SZheng Fan } } // end of namespace ::svx::sidebar
462