Context.cxx (22de8995) | Context.cxx (7a32b0c8) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 12 unchanged lines hidden (view full) --- 21 22#include "precompiled_sfx2.hxx" 23 24#include "Context.hxx" 25 26#define AnyApplicationName "any" 27#define AnyContextName "any" 28 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 12 unchanged lines hidden (view full) --- 21 22#include "precompiled_sfx2.hxx" 23 24#include "Context.hxx" 25 26#define AnyApplicationName "any" 27#define AnyContextName "any" 28 |
29namespace sfx2 { | 29namespace sfx2 { namespace sidebar { |
30 31const sal_Int32 Context::NoMatch = 4; | 30 31const sal_Int32 Context::NoMatch = 4; |
32const sal_Int32 Context::ApplicationWildcardMatch = 1; 33const sal_Int32 Context::ContextWildcardMatch = 2; |
|
32const sal_Int32 Context::OptimalMatch = 0; // Neither application nor context name is "any". 33 34#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 35 36Context::Context (void) 37 : msApplication(A2S(AnyApplicationName)), 38 msContext(A2S(AnyContextName)) 39{ --- 19 unchanged lines hidden (view full) --- 59 const bool bApplicationNameIsAny (rOther.msApplication.equalsAscii(AnyApplicationName)); 60 if (rOther.msApplication.equals(msApplication) || bApplicationNameIsAny) 61 { 62 // Application name matches. 63 const bool bContextNameIsAny (rOther.msContext.equalsAscii(AnyContextName)); 64 if (rOther.msContext.equals(msContext) || bContextNameIsAny) 65 { 66 // Context name matches. | 34const sal_Int32 Context::OptimalMatch = 0; // Neither application nor context name is "any". 35 36#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 37 38Context::Context (void) 39 : msApplication(A2S(AnyApplicationName)), 40 msContext(A2S(AnyContextName)) 41{ --- 19 unchanged lines hidden (view full) --- 61 const bool bApplicationNameIsAny (rOther.msApplication.equalsAscii(AnyApplicationName)); 62 if (rOther.msApplication.equals(msApplication) || bApplicationNameIsAny) 63 { 64 // Application name matches. 65 const bool bContextNameIsAny (rOther.msContext.equalsAscii(AnyContextName)); 66 if (rOther.msContext.equals(msContext) || bContextNameIsAny) 67 { 68 // Context name matches. |
67 return (bApplicationNameIsAny ? 1 : 0) 68 + (bContextNameIsAny ? 2 : 0); | 69 return (bApplicationNameIsAny ? ApplicationWildcardMatch : 0) 70 + (bContextNameIsAny ? ContextWildcardMatch : 0); |
69 } 70 } 71 return NoMatch; 72} 73 74 75 76 --- 16 unchanged lines hidden (view full) --- 93 return OptimalMatch; 94 } 95 nBestMatch = nMatch; 96 } 97 } 98 return nBestMatch; 99} 100 | 71 } 72 } 73 return NoMatch; 74} 75 76 77 78 --- 16 unchanged lines hidden (view full) --- 95 return OptimalMatch; 96 } 97 nBestMatch = nMatch; 98 } 99 } 100 return nBestMatch; 101} 102 |
101} // end of namespace sfx2 | 103 104 105 106bool Context::operator== (const Context& rOther) const 107{ 108 return msApplication.equals(rOther.msApplication) 109 && msContext.equals(rOther.msContext); 110} 111 112 113 114 115bool Context::operator!= (const Context& rOther) const 116{ 117 return ( ! msApplication.equals(rOther.msApplication)) 118 || ( ! msContext.equals(rOther.msContext)); 119} 120 121 122} } // end of namespace sfx2::sidebar |